part of 'page.dart';

class _HomePageView extends StatelessWidget {
  const _HomePageView({
    required _HomePageWloc wloc,
  }) : _wloc = wloc;

  static const double _iconSize = 28;

  final _HomePageWloc _wloc;

  @override
  Widget build(BuildContext context) {
    return CupertinoTheme(
      data: CupertinoTheme.of(context).copyWith(
        textTheme: CupertinoTextThemeData(
          tabLabelTextStyle: HomePageTheme.of(context).textTheme.tabBarLabel,
        ),
      ),
      child: Container(
        color: HomePageTheme.of(context).tabBarBackgroundColor,
        child: SafeArea(
          left: false,
          top: false,
          right: false,
          bottom: true,
          maintainBottomViewPadding: true,
          child: CupertinoTabScaffold(
            resizeToAvoidBottomInset: false,
            controller: _wloc.tabController,
            tabBar: CupertinoTabBar(
              height: kTabBarHeight,
              backgroundColor: HomePageTheme.of(context).tabBarBackgroundColor,
              items: [
                BottomNavigationBarItem(
                  icon: const Icon(
                    CustomSemiboldIcons.text_box_check,
                    size: _iconSize,
                  ),
                  label: HomeTranslation.of(context).collectionsTabLabel,
                ),
                BottomNavigationBarItem(
                  icon: const Icon(
                    CustomSemiboldIcons.rectangle_on_rectangle_angled,
                    size: _iconSize,
                  ),
                  label: HomeTranslation.of(context).learningTabLabel,
                ),
                BottomNavigationBarItem(
                  icon: const Icon(
                    Icons.menu_rounded,
                    size: _iconSize + 2,
                  ),
                  label: HomeTranslation.of(context).menuTabLabel,
                ),
              ],
              activeColor: CoreTheme.of(context).primaryColor,
              inactiveColor: HomePageTheme.of(context).tabBarInactiveColor,
              onTap: _wloc.onTabTap,
            ),
            tabBuilder: (context, index) {
              return switch (index) {
                0 => const CollectionTab(),
                1 => const LearningTab(),
                2 => const MenuTab(),
                _ => throw UnimplementedError(),
              };
            },
          ),
        ),
      ),
    );
  }
}
